<template>
  <div class="pd-le-ri">
    <div class="crumbs">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>
          <el-icon :size="11">
            <user-filled />
          </el-icon> 答题记录
        </el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="container">
      <div style="min-width: 800px; display: flex">
        <!-- <el-input placeholder="输入电话号码" style="width: 300px" v-model="phone" />
        <el-select v-model="regionId" class="m-2" placeholder="选择区域" style="margin-left: 30px;">
          <el-option v-for="item in typeList" :key="item.id" :label="item.campusName" :value="item.id" />
        </el-select>
        <div style="margin: 0 20px">
          <el-button type="primary" @click="clickBtn">搜索</el-button>
        </div> -->
      </div>
      <div style="margin: 20px 0 30px">
        <el-table :data="tableData.arr" border style="width: 100%" :stripe="true">
          <el-table-column prop="id" label="ID" width="100"></el-table-column>
          <el-table-column align="center" label="头像" width="200">
            <template v-slot="scope">
              <el-image style="width: 50px; height: 50px" fit="cover" :src="scope.row.userHandImg"
                :preview-src-list="[scope.row.userHandImg]"></el-image>
            </template>
          </el-table-column>
          <el-table-column prop="userName" label="用户名" width="350"></el-table-column>
          <el-table-column prop="categoryName" label="专栏" width="350"></el-table-column>
          <el-table-column prop="answerTime" label="答题时间" width="200"></el-table-column>
          <el-table-column prop="count" label="正确答题数" ></el-table-column>
          <!-- <el-table-column label="订单类型" width="100">
            <template v-slot="scope">
              <span v-if="scope.row.type == 'PICK'">快递</span>
              <span v-if="scope.row.type == 'PAINT'">打印</span>
              <span v-if="scope.row.type == 'HELP'">帮助</span>
              <span v-if="scope.row.type == 'RUN'">跑腿</span>
            </template>
          </el-table-column>
          <el-table-column prop="money" label="金额" width="100"></el-table-column>
          <el-table-column prop="endAddress" label="收货地址" width="250"></el-table-column>
          <el-table-column prop="createTime" label="时间" width="250"></el-table-column>
          <el-table-column label="状态" align="center" prop="state"></el-table-column>
          <el-table-column label="操作" width="200" align="center">
            <template v-slot="scope">
              <el-button type="primary" @click="getMoreMessage(scope.row)">更多信息</el-button>
            </template>
          </el-table-column> -->
        </el-table>
      </div>
      <div style="margin-bottom: 10px">
        <div class="demo-pagination-block">
          <el-pagination :page-size="10" layout="total, prev, pager, next, jumper" :total="total"
            @current-change="handleCurrentChange">
          </el-pagination>
        </div>
      </div>
    </div>
    <!-- <el-dialog v-model="dialogVisible" title="更多信息" width="30%">
      <div style="width: ;100%">
        <div class="msg_item">
          <div class="msg_left">取货人：</div>
          <div class="msg_right">{{ message.receiverHeadName }}</div>
        </div>
        <div class="msg_item">
          <div class="msg_left">取货人ID：</div>
          <div class="msg_right">{{ message.receiver }}</div>
        </div>
        <div class="msg_item">
          <div class="msg_left">取货号码：</div>
          <div class="msg_right">{{ message.receiverPhone }}</div>
        </div>
        <div class="msg_item">
          <div class="msg_left">收货起点：</div>
          <div class="msg_right">{{ message.startAddress }}</div>
        </div>
        <div class="msg_item">
          <div class="msg_left">备注：</div>
          <div class="msg_right">{{ message.mark }}</div>
        </div>
        <div class="msg_item" v-if="orderInfo.pickCode">
          <div class="msg_left">取件码：</div>
          <div class="msg_right">{{ orderInfo.pickCode }}</div>
        </div>
        <div class="msg_item" v-if="orderInfo.fileUrl">
          <div class="msg_left">文件地址：</div>
          <div class="msg_right">{{ orderInfo.fileUrl }}</div>
        </div>
        <div class="msg_item" v-if="orderInfo.identityUrl">
          <div class="msg_left">身份码：</div>
          <div class="msg_right">
            <img :src="orderInfo.identityUrl" class="imgs" />
          </div>
        </div>
      </div>
      <template #footer>
        <span class="dialog-footer">
          <el-button type="primary" @click="dialogVisible = false">确认</el-button>
        </span>
      </template>
    </el-dialog> -->
  </div>
</template>

<script lang="ts">
import { defineComponent, ref, reactive, onMounted } from "vue";
import { getOrderList, getType } from "../../http/order/order";
import { UserFilled } from "@element-plus/icons";

import {
  getUserAnswerRecord,
} from "../../http/school/school";

export default defineComponent({
  components: {
    UserFilled,
  },
  setup() {
    let tableData = reactive({
      arr: [],
    });
    let message: any = ref({});
    let orderInfo: any = ref({});
    let total = ref();
    let page = ref(1);
    const dialogVisible = ref(false);
    const phone = ref('');
    const regionId = ref('');
    let typeList:any = ref([]);

    onMounted(async () => {
      getList();
      // const res: any = await getType();
      // typeList.value = res.data;
    });

    const getList = async () => {
      const data = {
        pageNum: page.value,
        // phone: phone.value,
        // regionId: regionId.value,
        pageSize:10
      }
      const res: any = await getUserAnswerRecord(data);
      tableData.arr = res.data.records;
      total.value = res.data.total;
    };

    const handleCurrentChange = (e: number) => {
      page.value = e;
      getList()
    };

    const clickBtn = () => {
      getList();
    };

    const getMoreMessage = (data: any) => {
      message.value = data;
      orderInfo.value = data.orderInfo;
      dialogVisible.value = true;
    }

    return {
      tableData,
      total,
      dialogVisible,
      message,
      orderInfo,
      typeList,
      regionId,
      phone,
      handleCurrentChange,
      clickBtn,
      getMoreMessage
    };
  },
});
</script>

<style scoped>
.msg_item {
  display: flex;
  align-items: center;
  width: 100%;
  font-size: 20px;
  margin: 20px 0;
}

.msg_left {
  width: 100px;
  text-align: right;
}

.mg_right {
  text-align: left;
}

.imgs {
  width: 400px;
}
</style>
